from urllib.request import urlopen
from bs4 import BeautifulSoup

def down_pyjobs():
    text = urlopen('http://python.org/jobs').read()
    soup = BeautifulSoup(text, 'html.parser')

    jobs = set()
    for job in soup.body.section('h2'):
        jobs.add('{} ({})'.format(job.a.string, job.a['href']))

    print('\n'.join(sorted(jobs, key=str.lower)))

def test_local():
    text = open('tmp/test1.html', 'r').read()
    soup = BeautifulSoup(text, 'html.parser')

    jobs = set()
    for job in soup.body('h2'):
        jobs.add('{}'.format(job.string))

    print('\n'.join(sorted(jobs, key=str.lower)))

test_local()
